import pandas as pd
import numpy as np
from .graphPrompt import graphPrompt
def df2Graph(dataframe: pd.DataFrame,client, model=None) -> list:
    # dataframe.reset_index(inplace=True)
    results = dataframe.apply(
        lambda row: graphPrompt(client,row.text, {"chunk_id": row.chunk_id}, model),
        axis=1
    )
    # invalid json results in NaN
    results = results.dropna()
    results = results.reset_index(drop=True)
    ## Flatten the list of lists to one single list of entities.
    concept_list = np.concatenate(results).ravel().tolist()
    return concept_list